home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Resource for Source: C/C++
/
Resource for Source - C-C++.iso
/
codelib2
/
v_02_05
/
2n05064d
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
Text File
|
1995-11-01
|
375 b
|
23 lines
int *binsearch(int x, const int v[], size_t n)
{
size_t low = 0;
size_t high = n;
int mid;
while (low < high)
{
mid = (low + high) / 2;
if (x < v[mid])
high = mid;
else if (x > v[mid])
low = mid + 1;
else
return &v[mid];
}
return 0;
};